<%@page import="org.directwebremoting.json.types.JsonArray"%>
<%@page import="net.sf.json.util.JSONBuilder"%>
<%@page import="net.sf.json.util.JSONUtils"%>
<%@page import="org.directwebremoting.json.JsonUtil"%>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="http://struts.apache.org/tags-bean"  prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html"  prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"   prefix="c" %>
<%@ page   import="grupobbva.pe.operhc.domain.SegUsuario"%>
<%@ page   import="java.util.List"%>
<%@page import="grupobbva.pe.operhc.util.Constant"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%
String versionApp=(String)request.getSession().getAttribute(Constant.VERSIONAPP_SESSION);
%>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>Ofertas para el Cliente - Días de Liquidación</title>
	<link rel="stylesheet" type="text/css" media="screen" href="<%=request.getContextPath()%>/css/ui.jqgrid.css" />
	<link rel="stylesheet" type="text/css" media="screen" href="<%=request.getContextPath()%>/css/redmond/jquery-ui-1.8.2.custom.css" />
	<link rel="stylesheet" type="text/css" media="screen" href="<%=request.getContextPath()%>/css/operhc_style.css" />
	<link rel="stylesheet" type="text/css" media="screen" href="<%=request.getContextPath()%>/css/buttonOHC.css" />

	<script type="text/javascript" src='<%= request.getContextPath()%>/dwr/interface/ConsultaActualAction.js'></script>
	<script type='text/javascript' src='<%= request.getContextPath()%>/dwr/engine.js'></script>
	<script type='text/javascript' src='<%= request.getContextPath()%>/dwr/util.js'></script>	
	<script src="<%=request.getContextPath()%>/js/util/gridUtil.js" type="text/javascript"></script>
	<script src="<%=request.getContextPath()%>/js/jquery-1.7.1.js" type="text/javascript"></script>	
	<script src="<%=request.getContextPath()%>/js/i18n/grid.locale-es.js" type="text/javascript"></script>
	<script src="<%=request.getContextPath()%>/js/jquery.jqGrid.src.js" type="text/javascript"></script>
	<script src="<%=request.getContextPath()%>/js/grid.subgrid.js" type="text/javascript"></script>
	<script src="<%=request.getContextPath()%>/js/util/encabezado.js?ver<%=versionApp%>" type="text/javascript"></script>
	
</head>
<body>
<center>
<br />
<table id="lstRangosDiaLiq" class="grid">
</table>
<br/>
<a href="javascript:seleccionarRango();" class="buttonOHC">SELECCIONAR</a>

</center>
</body>
<script type="text/javascript" charset="UTF-8">

var rutaContexto1 = location.pathname;
var rutaContexto2 = "<%=request.getContextPath()%>";
var rutaContexto  = rutaContexto1.substr(0, rutaContexto1.indexOf(rutaContexto2)) + rutaContexto2;

<%SegUsuario usuarioSession = (SegUsuario)request.getSession().getAttribute("usuarioSession");%>

var myColNames  = ['','Rango', 'Fecha de Cierre', 'Fecha de Cargo'];
var myDataModel = [ {name : 'id',									width : VAL_WIDTH.XSMALL, formatter: radioFormat, fixed: true, sortable: false},
                    {name : 'rango',	index : 'rango', 			width : VAL_WIDTH.SMALL, sortable: false					},
                    {name : 'fechaCierre',	index : 'fechaCierre',	width : VAL_WIDTH.SMALL, sortable: false					},
                    {name : 'fechaCargo',	index : 'fechaCargo', 	width : VAL_WIDTH.SMALL, sortable: false					}                               
                   ];
                   
function radioFormat (cellValue, option) {
    return '<input type="radio" name="seleccion"  />';
}

function seleccionarRango() {
    var $selRadio = $('input[name=seleccion]:radio:checked'), $tr;
    if ($selRadio.length > 0) {
        $tr = $selRadio.closest('tr');
        if ($tr.length > 0) {
            //alert("Seleccionaste el id: " + $tr.attr('id'));
            var frameConsultaActual = window.opener.top.document.getElementsByName("frameConsultaActual")[0];
			var contentFrame = (frameConsultaActual.contentWindow || frameConsultaActual.contentDocument);
			var idx = jQuery("#lstRangosDiaLiq").getInd($tr.attr('id'));
			var rowData = jQuery("#lstRangosDiaLiq").jqGrid('getRowData', idx ); 
        	contentFrame.document.getElementById('hdnDiaLiquidacion').value = $tr.attr('id');
        	contentFrame.document.getElementById('rangoLiquidacion').value = rowData.rango; 
        }
        window.close();
    } else {
        alert("Seleccione un rango");
    }
};

                   
function mostrarTabla(data){
	jQuery("#lstRangosDiaLiq").jqGrid(
	{
		caption		: "Listado de Días de Liquidación",
		data 	 	: data,
		datatype 	: "local",
		height   	: "100%",
		colNames 	: myColNames,
		colModel 	: myDataModel,
		multiselect : false
	});
}

function cargarTabla() {
	jQuery("#lstRangosDiaLiq").GridUnload();
	tipoTarjeta = '<%=request.getAttribute("tipoTarjeta")%>';
	ConsultaActualAction.consultarDiasLiquidacionAjax(tipoTarjeta, function(data){
		if(data != null){
			mostrarTabla(data);
		}
	});
}

cargarTabla();

</script>

</html>